20230322
[shlib.git] / testing / 5.shlib_v0_3_testing.Testing for shlib v0_3.unit / 2.strfmt_testing.strfmt and strdispatch Testing.unit / 12.tmpl2txt_testing.sh
blobf47d2ea0e392b8262985e0e85fb6539b8ce455eb
1 #!/bin/bash
2 ############################################################
3 # source: file_inc_testing.sh
4 # author: devenkong(18151155@qq.com)
5 # date: 2021-10-03
6 ############################################################
7 # Copyright (C) 2022- Free Software Foundation, Inc.
8 # This configure script is free software; the Free Software
9 # Foundation gives unlimited permission to copy, distribute
10 # and modify it.
11 ############################################################
12 # note:
13 # this is a testing script for shlib file including. it
14 # test different include paths by user setting, and test
15 # if the including shlib works.
16 ############################################################
19 # source it first.
20 . shlibinc
21 include stdio.shlib
22 include dbgout.shlib
23 include term.shlib
25 include attr.shlib
26 include strfmt.shlib
28 ############################################################
30 #TESTING_ROOT_DIR=
31 #TESTING_TMP_DIR=~/.testing/$0/
34 HDRB="${BCMAGENTA}${CHIGHL}"
35 HDRE="${CNORMAL}"
37 IMPB="${FCMAGENTA}${CHIGHL}"
38 IMPE="${FCCYAN}${CHIGHL}"
41 # fdesc: debug string for test program hint. it outputed with color.
42 # but the "=" signature is not putted in this function. it is
43 # used to show difference in code. developer can recognize it
44 # to get the debug info clearly.
46 TDBGOUT ()
48 dbgout "${FCCYAN}${CHIGHL}$@${CNORMAL}\n"
52 #####################################################################
54 attr_declare SRCFILE="test.sh"
55 attr_declare AUTHOR="test"
56 attr_declare DATE="$(date +%Y-%m-%d)"
57 attr_declare NOTE="
58 # this is a templete of file header."
60 # all string content is a variable.
61 attr_declare SHEBANG='#!/bin/bash'
62 # variable is at the beginning of a string.
63 attr_declare TESTING='output test string in a variable.'
64 # variable at the end of a string.
65 attr_declare SRCFILE='strfmt.shlib'
66 # multi-var in a line. there are string between variables.
67 attr_declare AUTHOR='devenkong'
68 attr_declare EMAIL='devenkong@126.com'
69 # $(date +%Y-%m-%d), use static value instead for test checking.
70 # multi-var in a line. a variable followed with another directly.
71 attr_declare DATE='2022-11-23'
72 # test for @(cmd).
73 attr_declare TIME='@(echo 10:20:30)'
74 # a variable in the middle of a string.
75 attr_declare COPYRIGHT_DATE='2022- '
76 # nest variable.
77 attr_declare COPYING='# Copyright (C) @{COPYRIGHT_DATE}- Free Software Foundation, Inc.
78 # This configure script is free software; the Free Software
79 # Foundation gives unlimited permission to copy, distribute
80 # and modify it.'
81 # test for multi-line variable.
82 attr_declare NOTE='
83 # this file is a string templete library.
84 # it like the function printf in c language. it also provide
85 # reverse operation to recognize variable string by the same format
86 # string.'
88 attr_declare INC_FILE_LIST='.shlibinc
90 @<[libinc[libinc]]include @<[inclibname]stdio.shlib>'
92 attr_declare str_tmpl="
93 this is a text for strfmt() testing.
94 ${SHEBANG}
95 ############################################################
96 ${TESTING} for pure testing.
97 # source: @{SRCFILE}
98 # author: @{AUTHOR} (email:@{EMAIL})
99 # date: @{DATE}@{TIME}
100 ############################################################
101 ${COPYING}
102 ############################################################
103 # note: ${NOTE}
104 ############################################################
106 #####################
107 # include file.
108 #####################
109 @{INC_FILE_LIST}
113 main ()
115 echo -ne "=================================\n"
116 echo -ne "= include lib path testing.\n"
118 dbgoutd "=================================\n"
119 TDBGOUT "= if this string is displayed on screen,"
120 TDBGOUT "= that means shlib of stdio.shlib is included by 'include' cmd."
122 dbgoutd "SHLIB_LIST=$SHLIB_LIST\n"
123 dbgoutd "SHLIB_INC_LIST=$SHLIB_INC_LIST\n"
125 dbgoutd "=================================\n"
126 dbgoutd "= ${HDRB}append shlib path manully by var assignment.${HDRE}\n"
127 dbgoutd "=================================\n"
128 TDBGOUT "= current shlib paths:"
130 TDBGOUT "= create lib path dir '~/.testing/shlib1',"
131 TDBGOUT "= and append it to SHLIB_PATH by var assignment."
133 dbgoutd "=================================\n"
134 dbgoutd "= 1.${HDRB}strfmt() testing.${HDRE}\n"
135 dbgoutd "=================================\n"
136 TDBGOUT "= strfmt @str_tmpl."
137 attr_get str_tmpl
138 strfmt @str_tmpl
140 dbgoutd "=================================\n"
141 TDBGOUT "= in the upper example, uniq.shlib is existing in \$PWD/uniq.shlib,"
142 TDBGOUT "= so include example.shlib with ${IMPB}uniq.shlib does not report errors${IMPE}."
144 dbgoutd "=================================\n"
145 dbgoutd "= ${HDRB}end of include path testing.${HDRE}\n"
146 dbgoutd "=================================\n"
149 main "$@"